package org.finir.fakturisanje.persistence.beans;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.finir.fakturisanje.persistence.Faktura;
import org.finir.fakturisanje.persistence.PoreskaTarifa;
import org.finir.fakturisanje.persistence.StavkaFakture;
import org.finir.fakturisanje.persistence.Usluga;
import org.jboss.seam.annotations.Name;

@Entity
@Name("stavkaFakture")
public class StavkaFaktureBean implements Serializable, StavkaFakture {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long id;
	private Integer rb;
	private String jedinicaMere;
	private PoreskaTarifa poreskaTarifa;
	private Double cena;
	private Double vrednost;
	private Double kolicina;
	private Faktura faktura;
	private Usluga usluga;
	private String opis;

	public String getOpis() {
		return opis;
	}

	public void setOpis(String opis) {
		this.opis = opis;
	}

	@ManyToOne(targetEntity = UslugaBean.class)
	public Usluga getUsluga() {
		return usluga;
	}

	public void setUsluga(Usluga usluga) {
		this.usluga = usluga;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getRb()
	 */
	public Integer getRb() {
		return rb;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setRb(java.lang.Integer)
	 */
	public void setRb(Integer rb) {
		this.rb = rb;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getJedinicaMere()
	 */
	public String getJedinicaMere() {
		return jedinicaMere;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setJedinicaMere(java.lang.String)
	 */
	public void setJedinicaMere(String jedinicaMere) {
		this.jedinicaMere = jedinicaMere;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getPoreskaTarifa()
	 */
	@ManyToOne(targetEntity = PoreskaTarifaBean.class)
	public PoreskaTarifa getPoreskaTarifa() {
		return poreskaTarifa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setPoreskaTarifa(domain.PoreskaTarifa)
	 */
	public void setPoreskaTarifa(PoreskaTarifa poreskaTarifa) {
		this.poreskaTarifa = poreskaTarifa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getCena()
	 */
	public Double getCena() {
		return cena;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setCena(java.lang.Double)
	 */
	public void setCena(Double cena) {
		this.cena = cena;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getVrednost()
	 */
	public Double getVrednost() {
		return vrednost;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setVrednost(java.lang.Double)
	 */
	public void setVrednost(Double vrednost) {
		this.vrednost = vrednost;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getKolicina()
	 */
	public Double getKolicina() {
		return kolicina;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setKolicina(java.lang.Integer)
	 */
	public void setKolicina(Double kolicina) {
		this.kolicina = kolicina;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#getFaktura()
	 */
	@ManyToOne(targetEntity = FakturaBean.class)
	@JoinColumn(nullable = false)
	public Faktura getFaktura() {
		return faktura;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.ff#setFaktura(domain.Faktura)
	 */
	public void setFaktura(Faktura faktura) {
		this.faktura = faktura;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof StavkaFaktureBean)) {
			return false;
		}
		StavkaFaktureBean other = (StavkaFaktureBean) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "stavka id = " + id + " rb=" + rb;
	}

}
